package com.st.app.house.web;

import com.st.app.house.entities.HouseEntity;
import com.st.app.house.service.HouseService;
import org.springframework.aot.hint.annotation.Reflective;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 测试:
 * *
 *
 * @author future
 * @date 11/25/24
 */


@RestController
class HelloController {

    @Autowired
    private HouseService houseService;

    @GetMapping("/")
     public String toIndex(){
         System.out.println("hello world");
        String msg = "hello web app";

        return msg;
     }

    @GetMapping("/list")
    public String list(){
        System.out.println("hello world");
        String msg = "hello web app";
        List<HouseEntity> allHouseEntities = houseService.getAllHouseEntities();

        System.out.println(allHouseEntities);
        return msg;
    }

    @GetMapping("/add")
    public String add(){
    	HouseEntity houseEntity = new HouseEntity();
    	houseEntity.setName("test");
    	houseEntity.setEmail("test@qq.com");
        System.out.println(houseEntity.toString());
    	houseService.createHouseEntity(houseEntity);

        System.out.println("添加============");
    	return "success";
    }
     @GetMapping("/del")
    public String del(){
    	houseService.deleteHouseEntity(1L);
         System.out.println("删除============");
    	return "success";
    }
}
